<template>
	<view>
		<view class="bg"></view>
		<button class="add">
			<image src="/static/coupon/加号.png" mode=""></image>
			<text>新增优惠券</text>
		</button>
		<view class="container">
			<view class="btn">
				<button @click="setStatus(1)" :style="status == 1 ? 'background-color:#2F81FA; color: #FFFFFF;' : 'background-color:#e9e9eb; color: #2F81FA;' ">进行中</button>
				<button @click="setStatus(0)":style="status == 1 ? 'background-color:#e9e9eb; color: #2F81FA;' : 'background-color:#2F81FA; color: #FFFFFF;' ">已结束</button>
			</view>
			<view v-for="(item,index) in dataList" :key="index" :style="status == 0 ? 'opacity: 0.6' : ''">
				<view class="item-bg" v-if="item.status == status" >
					<!-- $20 -->
					<view class="price">
						<view class="condition">满{{item.condition}}元可用</view>
						￥
						<text>{{item.price}}</text>
					</view>
					<view class="detail">
						<view class="name">{{item.name}}</view>
						<view class="time">有效期: {{item.begainTime}}-{{item.endTime}}</view>
						<view class="" style="font-size: 16rpx;">
							每人限领一张
						</view>
						<view class="over" v-if="status == 0">
							已结束
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: 1,
				dataList: [
					{
						name: '优惠券名称:新用户专享体验券',
						begainTime: '2020.3.18',
						endTime: '2023.4.18',
						condition: 200,
						price: 20,
						status: 1
					},
					{
						name: '优惠券名称:新用户专享体验券',
						begainTime: '2020.3.18',
						endTime: '2023.4.18',
						condition: 200,
						price: 20,
						status: 1
					},
					{
						name: '优惠券名称:新用户专享体验券',
						begainTime: '2020.3.18',
						endTime: '2023.4.18',
						condition: 200,
						price: 20,
						status: 1
					},
					{
						name: '优惠券名称:新用户专享体验券',
						begainTime: '2020.3.18',
						endTime: '2023.4.18',
						condition: 200,
						price: 20,
						status: 0
					},
					{
						name: '优惠券名称:新用户专享体验券',
						begainTime: '2020.3.18',
						endTime: '2023.4.18',
						condition: 200,
						price: 20,
						status: 0
					}
				]
			}
		},
		methods: {
			setStatus(data) {
				this.status = data
			}
		}
	}
</script>

<style>
	.bg {
		height: 400rpx;
		background-color: #3486FD;
	}

	.add>image {
		width: 30rpx;
		height: 30rpx;
		margin-right: 30rpx;
	}

	.add>text {
		color: #3486FD;
	}

	.add {
		width: 650rpx;
		border-radius: 50rpx;
		position: absolute;
		top: 20rpx;
		right: 50rpx;
	}
	
	.container {
		padding: 30rpx;
		margin: 0 30rpx;
		margin-top: -250rpx;
		background-color: #FFFFFF;
		border-radius: 30rpx;
	}

	.btn {
		display: flex;
		justify-content: center;
		margin-bottom: 60rpx;
	}

	.btn>button {
		margin: 0;
		line-height: 80rpx;
	}
	
	.btn>button:nth-child(1) {
		border-top-left-radius: 50rpx;
		border-bottom-left-radius: 50rpx;
		padding-left: 60rpx;
	}
	
	.btn>button:nth-child(2) {
		border-top-right-radius: 50rpx;
		border-bottom-right-radius: 50rpx;
		padding-right: 60rpx;
	}
	.item-bg {
		background-image: url('/static/coupon/组 5.png');
		background-repeat: no-repeat;
		width: 100%;
		height: 225rpx;
		display: flex;
		align-items: center;
		position: relative;
		margin-bottom: 30rpx;
	}
	
	.price {
		font-weight: bold;
		color: #FFFFFF;
		width: 200rpx;
		text-align: center;
		margin-right: 10rpx;
	}
	
	.price>text{
		font-size: 80rpx;
	}
	
	.name {
		font-weight: bold;
		font-size: 28rpx;
	}
	
	.condition {
		font-size: 16rpx;
		font-weight: bold;
		margin-bottom: 30rpx;
	}
	
	.time {
		font-size: 16rpx;
		margin-bottom: 20rpx;
	}
	
	.over {
		width: 120rpx;
		padding: 0 20rpx;
		font-size: 36rpx;
		font-weight: bold;
		border: 7rpx solid #CCCCCC;
		position: absolute;
		color: #CCCCCC;
		right: 20rpx;
		bottom: 20rpx;
		transform: rotate(-10deg);
		transform-origin: bottom left;
	}
</style>